package com.he.fetch.util;

import java.util.ResourceBundle;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.he.fetch.model.FetchSet;

public class Factory {

    private static Factory factory;

    public static Factory getInstance() {
	if (factory == null) {
	    factory = new Factory();
	    ResourceBundle bundle = ResourceBundle.getBundle(Factory.class
		    .getName());
	    String configLocation = bundle.getString("config.location");
	    factory.context = new ClassPathXmlApplicationContext(configLocation);
	}
	return factory;
    }

    private ApplicationContext context;

    private Factory() {
    }

    public FetchSet getFetchFieldSet(String name) {
	return this.context.getBean(name, FetchSet.class);
    }

}
